package com.sec.etech.ism.factory;

import com.sec.etech.ism.service.IsmMethodService;
import org.openbpm.base.api.exception.BusinessException;
import org.openbpm.base.core.util.AppUtil;

import java.util.Map;

public class IsmFactory {
    private IsmFactory(){}

    /*public static IsmAppService getIsmAppService(String sysName) {
        Map<String, IsmAppService> map = AppUtil.getImplInstance(IsmAppService.class);
        for (Map.Entry<String, IsmAppService> entry : map.entrySet()) {
            if (entry.getValue().sysName().equals(sysName)) {
                return entry.getValue();
            }
        }
        throw new BusinessException(String.format("找不到应用[%s]的实现类", sysName));
    }*/

    public static IsmMethodService getIsmMethodService(String methodName) {
        Map<String, IsmMethodService> map = AppUtil.getImplInstance(IsmMethodService.class);
        for (Map.Entry<String, IsmMethodService> entry : map.entrySet()) {
            if (entry.getValue().methodName().equals(methodName)) {
                return entry.getValue();
            }
        }
        throw new BusinessException(String.format("找不到应用[%s]的实现类", methodName));
    }
    /**
     * <pre>
     * 返回默认的实现类
     * </pre>
     *
     * @return
     */
    /*public static IsmAppService getDefault() {
        return getIsmAppService("SAP");
    }*/
}
